package video

import (
	"dy/pkg/code"

	"github.com/gin-gonic/gin"
)

func (u *ControllerVideo) Feed(ctx *gin.Context) {
	type param struct {
		LatestTime int    `form:"latest_time" json:"latest_time"`
		Token      string `form:"token" json:"token"`
	}

	var request param
	err := ctx.Bind(&request)
	if err != nil {
		code.ErrReturn(ctx, err.Error())
		return
	}

	list, nextTime, err := u.srv.Video().List(ctx, 0)
	if err != nil {
		code.ErrReturn(ctx, err.Error())
		return
	}

	ctx.JSON(200, gin.H{
		"status_code": 0,
		"status_msg":  "success",
		"video_list":  list,
		"next_time":   nextTime,
	})
	return
}
